package com.zqwh.xtool.model.other;

import android.content.Context;

import com.zqwh.yj.sdk.utils.httpRequest.RetrofitSingleton;
import com.zqwh.yj.sdk.utils.httpRequest.subscribers.NetCallback;
import com.zqwh.yj.sdk.utils.httpRequest.subscribers.ProgressSubscriber;
import com.zqwh.xtool.api.VersionApi;
import com.zqwh.xtool.config.BaseConfig;
import com.zqwh.xtool.domain.VersionResult;
import com.zqwh.xtool.model.VersionModel;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class VersionModelImpl implements VersionModel {
    private VersionApi versionApi;
    private Context context;

    public VersionModelImpl(Context context) {
        this.context = context;
        this.versionApi = RetrofitSingleton.getInstance(BaseConfig.BASE_URL).create(VersionApi.class);
    }
    @Override
    public void getLatestVersion(NetCallback<VersionResult> callback) {
        versionApi.getLatestVersion(2)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ProgressSubscriber(callback, context, false));
    }
}
